﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NS_DBOP;

public partial class sysManage_UpdatePwd : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        string oldpwd = this.txtOldPwd.Text;
        string newpwd = this.txtNewPwd.Text;
        object pwds = new DBoperate().ExecuteScalar("select Password from UserInfo where UserName='" + Session["UserName"].ToString()+ "'");
        string pwd = Convert.ToString(pwds);
        if (oldpwd.Equals(pwd))
        {
            int result = new DBoperate().ExecuteUpdate("update UserInfo set Password='" + newpwd + "' where UserName='" + Session["UserName"] + "'");
            if (result > 0)
            {
                Response.Write("<script language=javascript>alert('修改成功！')</script>");
            }
            else
            {
                Response.Write("<script language=javascript>alert('修改成功！')</script>");
            }
        }
        else
        {
            Response.Write("<script language=javascript>alert('旧密码不正确，不能进行修改！')</script>");
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        this.txtOldPwd.Text = "";
        this.txtNewPwd.Text = "";
        this.txtAffirm.Text = "";
    }
}
